Hi, my self Ravi Vishwakarma. I have completed my studies at SPICBB Varanasi. now I completed MCA with 76% form Veer Bahadur Singh Purvanchal University Jaunpur.
SWE @ MindStick | Software Engineer | Web Developer | .Net Developer | Web Developer | Backend Engineer | .NET Core Developer
A graph is a non-linear data structure consisting of a set of vertices/nodes connected by edges/lines. It is used to represent connections or relationships between different objects or entities. Graphs are widely used in computer science, social networking, transportation networks, and many other fields.
There are two common types of graphs: directed and undirected graphs. In a directed graph, each edge has a direction, while in an undirected graph, the edges have no direction. Each edge can also have a weight or cost associated with it, which represents the cost of moving from one node to another.
Here is an example of an undirected graph:
A--B
|\ |
| \|
C--D
In this graph, there are four vertices/nodes (A, B, C, and D) and five edges connecting them. The edges between nodes A and B, B and C, C and D, and A and D are unweighted, meaning that the cost of moving between these nodes is the same. The edge between nodes A and C has a weight of 2, meaning that it is more costly to move between these nodes than between the others.
This graph can be represented in various ways, such as an adjacency matrix or adjacency list. In an adjacency matrix, each row and column represents a node, and the matrix element at row i and column j represents the weight of the edge connecting nodes i and j. In an adjacency list, each node is represented as a list, and the list contains the nodes that are connected to it.
Graphs are useful for many types of problems, such as finding the shortest path between two nodes, identifying cycles in a network, or identifying connected components in a graph.
In computer science, a graph is a data structure that consists of a set of nodes (also known as vertices) and a set of edges that connect pairs of nodes. Graphs are used to represent relationships between objects, and they have a wide range of applications in fields such as computer networking, social networks, and transportation networks.
A simple example of a graph is a social network, such as Facebook or LinkedIn. In this case, each user is represented as a node in the graph, and the connections between users (i.e. who is friends with whom) are represented as edges. For example, let's say we have three users: Alice, Bob, and Charlie. If Alice is friends with Bob and Charlie is friends with Alice, we can represent this relationship using the following graph:
In this graph, each node represents a user, and each edge represents a connection between users. The edge connecting Alice and Bob indicates that they are friends, while the edge connecting Alice and Charlie indicates that they are also friends.
This is just a simple example of a graph, and real-world graphs can be much larger and more complex. Nonetheless, the basic structure remains the same: a set of nodes and a set of edges that connect those nodes.
A graph is a type of data structure that is non-linear. It consists of nodes( also referred to as vertices) and edges. A graph represents the relationship between various objects.
This is a graph with six vertices (A, B, C, D, E, F) and seven edges connecting them. Each edge represents a relationship between two nodes. For example, there is an edge connecting node A and node B, indicating that there is a relationship between them.
Graphs are used to represent social networks, transportation networks, and computer networks.
Liked By
Write Answer
What is a graph in Data Structure, explain it with an example.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy
Join MindStick Community
You have need login or register for voting of answers or question.
Aryan Kumar
24-Apr-2023A graph is a non-linear data structure consisting of a set of vertices/nodes connected by edges/lines. It is used to represent connections or relationships between different objects or entities. Graphs are widely used in computer science, social networking, transportation networks, and many other fields.
There are two common types of graphs: directed and undirected graphs. In a directed graph, each edge has a direction, while in an undirected graph, the edges have no direction. Each edge can also have a weight or cost associated with it, which represents the cost of moving from one node to another.
Here is an example of an undirected graph:
In this graph, there are four vertices/nodes (A, B, C, and D) and five edges connecting them. The edges between nodes A and B, B and C, C and D, and A and D are unweighted, meaning that the cost of moving between these nodes is the same. The edge between nodes A and C has a weight of 2, meaning that it is more costly to move between these nodes than between the others.
This graph can be represented in various ways, such as an adjacency matrix or adjacency list. In an adjacency matrix, each row and column represents a node, and the matrix element at row i and column j represents the weight of the edge connecting nodes i and j. In an adjacency list, each node is represented as a list, and the list contains the nodes that are connected to it.
Graphs are useful for many types of problems, such as finding the shortest path between two nodes, identifying cycles in a network, or identifying connected components in a graph.
Rocky Dada
07-Apr-2023In computer science, a graph is a data structure that consists of a set of nodes (also known as vertices) and a set of edges that connect pairs of nodes. Graphs are used to represent relationships between objects, and they have a wide range of applications in fields such as computer networking, social networks, and transportation networks.
A simple example of a graph is a social network, such as Facebook or LinkedIn. In this case, each user is represented as a node in the graph, and the connections between users (i.e. who is friends with whom) are represented as edges. For example, let's say we have three users: Alice, Bob, and Charlie. If Alice is friends with Bob and Charlie is friends with Alice, we can represent this relationship using the following graph:
In this graph, each node represents a user, and each edge represents a connection between users. The edge connecting Alice and Bob indicates that they are friends, while the edge connecting Alice and Charlie indicates that they are also friends.
This is just a simple example of a graph, and real-world graphs can be much larger and more complex. Nonetheless, the basic structure remains the same: a set of nodes and a set of edges that connect those nodes.
Krishnapriya Rajeev
27-Mar-2023A graph is a type of data structure that is non-linear. It consists of nodes( also referred to as vertices) and edges. A graph represents the relationship between various objects.
This is a graph with six vertices (A, B, C, D, E, F) and seven edges connecting them. Each edge represents a relationship between two nodes. For example, there is an edge connecting node A and node B, indicating that there is a relationship between them.
Graphs are used to represent social networks, transportation networks, and computer networks.